home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / Mac⁄gnuucp 6.14 / source / uucp protocol info < prev    next >
Encoding:
Internet Message Format  |  1991-02-13  |  44.5 KB  |  [TEXT/R*ch]

  1. From f87-sir@nada.kth.se Wed, 13 Feb 91 07:26:50 EDT remote from fpr
  2. Received: by fpr (Mac/gnuucp v4.3) Wed, 13 Feb 91 07:26:50 EDT
  3. Received: from dront.nada.kth.se by uu.psi.com (5.61/3.1.090690-Performance Systems International)
  4.     id AA00726; Wed, 13 Feb 91 01:20:21 -0500
  5. Received: by dront.nada.kth.se (5.61-bind 1.4+ida/nada-mx-1.0)
  6.     id AA27813; Wed, 13 Feb 91 07:20:55 +0100
  7. Message-Id: <9102130620.AA27813@dront.nada.kth.se>
  8. Cc: f87-sir@nada.kth.se
  9.  
  10. > message from Ian Feldman, do not (R)eply, MAIL to 'ianf@random.se' only
  11.  
  12.  
  13. Jim,
  14.   I enclose what appears to be the only uucp packet documentation that's
  15.   avaialble from my guru... perhaps you could search for more by turning
  16.   directly to people listed in the headers.  I'll try to 'wiggle' some
  17.   additional info from Stuart Lynne, member of the 1985 original uuPC
  18.   coding team (endeavor??) though. 
  19.  
  20. Note #1: set your TAB value to 8 when reading the documentation that's
  21.   included.
  22.  
  23. Note #2: I've taken the nroff-ed source text and run it through deroff
  24.   for your reading convenience (appended last). My deroff appears
  25.   however to be of a very simple sort... it didn't fold the lines
  26.   properly so I had to do it manually afterwards.  Thereofe I might have
  27.   botched it up somehow.  Please consult the nroff original if in doubt.
  28.  
  29.  
  30. --Ian
  31.  
  32.  
  33. # To: ber@sunic.sunet.se
  34. # Date: 12 Feb 1991 @ 18.18 (tis, 12 feb 91 18:56:55)
  35. # Subject: Re: failed uucp transfers 
  36.  
  37. > Date: Fri, 08 Feb 91 09:47:25 +0100
  38. > From: ber@sunic.sunet.se
  39. > Looking at the code:
  40. >       /* dont send him files he can't save */
  41. >       if (strcmp(&msg[1], EM_NOTMP) == 0) {
  42. >         WMESG(HUP, "");
  43. >         RMESG(HUP, msg, 1);
  44. >         goto process;
  45. >       }
  46. >       notify(mailopt, W_USER, W_FILE1, Rmtname, &msg[1]);
  47. > then it would be better to send CN4 (=EM_NOTMP) as that would do what you
  48. > want. Your end should then answer HY on the HUP? question from sunic.
  49.  
  50.   Apparently the GNUUCP code isn't documented over and above the usual
  51.   programmer's notes in the relevant routines.  Could you perhaps point me
  52.   to the documentation of the uucp protocoll (perhaps attached to some
  53.   known uucp sources, that are available via ftp) and/ or supply a complete
  54.   list of all error codes and their meanings?
  55.  
  56.   Thanks once again in advance.
  57. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
  58.  
  59.  
  60. # Message-Id: <9102122247.AAsunic05069@sunic.sunet.se>
  61. # To: ianf@random.se
  62. # Subject: Re: failed uucp transfers 
  63. # Date: Tue, 12 Feb 91 23:47:04 +0100
  64. # From: ber@sunic.sunet.se
  65.  
  66. > Apparently the GNUUCP code isn't documented over and above the usual
  67. > programmer's notes in the relevant routines.  Could you perhaps point 
  68. > me to the documentation of the uucp protocoll 
  69.  
  70.   There is just no such thing as a complete documentation of the uucp
  71.   implementation, as it's still part of the Unix source and thus
  72.   trademark of AT&T and require a source license in order to see the
  73.   actual code.
  74.  
  75.   The only describtion I have is this old one:
  76.  
  77. Path: enea!mcvax!uunet!husc6!cmcl2!nrl-cmf!ames!sdcsvax!brian
  78. >From: brian@sdcsvax.UCSD.EDU (Brian Kantor)
  79. Newsgroups: comp.doc
  80. Subject: UUCP Protocol Information Potpourri
  81. Message-ID: <4513@sdcsvax.UCSD.EDU>
  82. Date: 20 Jan 88 02:04:02 GMT
  83. Organization: UCSD wombat breeding society
  84. Lines: 1047
  85. Approved: brian@cyberpunk.ucsd.edu
  86.  
  87.   The following is collection of stuff that John Gilmore posted to the net
  88.   some time ago; with renewed interest in making nearly everything under
  89.   the sun talk uucp, I figured it was time this document appeared
  90.   somewhere that it would get archived for future inquiries. 
  91.  
  92. >From ucsdhub!hp-sdd!hplabs!decwrl!sun!hoptoad!gnu Tue Feb  3 13:10:08 PST 1987
  93.  
  94.   [This information came from the Tanner Andrews's uucpinfo mailing list. 
  95.   This is a collection of people interested in writing a version of uucp
  96.   in the public domain.  Contact ihnp4!akgua!ucf-cs!ki4pv!tanner to be
  97.   added to the mailing list.  There have only been three messages sent to
  98.   the list; all are below. 
  99.  
  100.     John Gilmore, hoptoad!gnu]
  101.  
  102. -----
  103.  
  104. Subject: UUCP Protocol Information (issue #1)
  105. Date: Tue Nov 19 22:04:56 1985
  106.  
  107.   Greetings.  First order of business is the fact that I probably have a
  108.   lousy or a slow address for some of you all.  Please complain, and
  109.   things will be corrected.  Those of you not receiving this because your
  110.   names have been omitted will please inform me, giving a good address. 
  111.   Those who provided replies but who are not interested in receiving
  112.   further information please warn me; maybe things won't cross in the
  113.   mail. 
  114.   
  115.   Now that we're over that, welcome to the first issue.  There will most
  116.   likely be more, as more information is received.  Anyone with comments,
  117.   information, or clean suggestions to be shared should please write to me
  118.   at the return address given below.  I'll keep the copy of this mailing
  119.   list around, and make required additions, deletions, &c.  This issue is
  120.   just a "welcome" and mailing-error-finder.  Sorry about the delay
  121.   between your "me-too" mailing and the actual goodstuff. 
  122.   
  123.   This is being issued as a mailing list because, while I have some of the
  124.   required information, there is still rather a shortage.  Research is
  125.   expected to improve the situation. 
  126.   
  127.   The second issue of this will be coming out almost immediately, and will
  128.   contain the bulk of the preliminary information which I have.  It will
  129.   also include a summary which has been tempered by experience on this
  130.   system (type ~uucp_adm/uucico on my terminal, watch the fun begin). 
  131.  
  132. My address is:
  133.   uucp:  ...{decvax|akgua}!ucf-cs!ki4pv!tanner
  134.   csnet:  ki4pv!tanner@ucf-cs.csnet
  135.   arpa:  ki4pv!tanner%ucf-cs.csnet@csnet-relay.arpa
  136.  
  137.             Tanner Andrews, systems
  138.             CompuData South,
  139.             P.O.Box 3636,
  140.             DeLand, FLA   32723.
  141.  
  142.  
  143. >From: ihnp4!akgua!ucf-cs!ki4pv!tanner
  144. To: ucf-cs!ki4pv-uucpinfo2, ucf-cs!ki4pv-uucpinfo1
  145. Subject: UUCP Information Issue #02
  146. Date: Wed Dec 11 23:39:26 1985
  147.  
  148.   This is the second issue; the information below is the start of what has
  149.   been collected here.  It is expected that more information will be
  150.   collected in the next few weeks, and that information will be forwarded
  151.   when/if it becomes available. 
  152.  
  153.   =====================================================
  154.   -- part 1
  155.   =====================================================
  156.  
  157.   This information came via several people, most of whom snet this exact
  158.   message (probably from their news archives from before we joined the
  159.   net):
  160.  
  161.     I am posting this over the network because I believe that
  162.     others are interested in knowing the protocols of UUCP.
  163.     Below is listed all the information that I have acquired
  164.     to date. This includes the initial handshaking phase, though
  165.     not the login phase. It also doesn't include information
  166.     about the data transfer protocol for non-packet networks
  167.     (the -G option left off the uucico command line). But, just
  168.     hold on - I am working on that stuff.
  169.  
  170.     For a point of information : the slave is the UUCP site being
  171.     dialed, and the master is the one doing the calling up. The
  172.     protocols listed in the handshaking and termination phase are
  173.     independent of any UUCP site : it is universal. The stuff in
  174.     the work phase depends on the specific protocol chosen. The
  175.     concepts in the work phase are independent of protocol, ie. the
  176.     sequences are the same. It is just the lower level stuff that
  177.     changes from protocol to protocol. I have access only to level
  178.     g and will document it as I begin to understand it.
  179.  
  180.     Most of the stuff you see here is gotten from the debug phase
  181.     of the current BSD UUCP system.
  182.  
  183.     I hope this is useful. Maybe this will get some of the real
  184.     'brains' in UUCP to get off their duffs and provide some real
  185.     detail. In any case, if you have any questions please feel
  186.     free to contact me. I will post any questions and answers over
  187.     the network.
  188.  
  189.  
  190.                 Chuck Wegrzyn
  191.                 {allegra,decvax,ihnp4}!encore!wegrzyn
  192.  
  193.                 (617) 237-1022
  194.  
  195.  
  196.  
  197.             UUCP Handshake Phase
  198.             ====================
  199.  
  200. Master                            Slave
  201. ------                            -----
  202.  
  203.                     <-----        \020Shere\0     (1)
  204.  
  205.  
  206. (2)  \020S<mastername> <switches>\0    ----->
  207.  
  208.  
  209.                     <-----        \020RLCK\0      (3)
  210.                             \020RCB\0
  211.                             \020ROK\0
  212.                             \020RBADSEQ\0
  213.  
  214.                     <-----        \020P<protos>\0 (4)
  215.  
  216.  
  217. (5) \020U<proto>\0            ----->
  218.     \020UN\0
  219.  
  220.  
  221. (6) ...
  222.  
  223.  
  224. (0) This communication happens outside of the packet communication that
  225.     is supported. If the -G flag is sent on the uucico line, all
  226.     communications will occur without the use of the packet
  227.     simulation software. The communication at this level is just
  228.     the characters listed above.
  229.  
  230. (1) The slave sends the sequence indicated, while the master waits for
  231.     the message.
  232.  
  233. (2) The slave waits for the master to send a response message. The message
  234.     is composed of the master's name and some optional switches.
  235.     The switch field can include the following
  236.  
  237.             -g        (set by the -G switch on the
  238.                      master's uucico command line.
  239.                      Indicates that communication
  240.                      occurs over a packet switch net.)
  241.             -xN        (set by the -x switch on the
  242.                      master's uucico command line.
  243.                      The number N is the debug level
  244.                      desired.)
  245.             -QM        (M is really a sequence number
  246.                      for the communication.)
  247.  
  248.     Each switch is separated from the others by a 'blank' character.
  249.  
  250. (3) The slave will send one of the many responses. The meanings appear 
  251.     to be :
  252.  
  253.     RLCK
  254.         This message implies that a 'lock' failure occurred:
  255.         a file called LCK..mastername couldn't be created since
  256.         one already exists. This seems to imply that the master
  257.         is already in communication with the slave.
  258.  
  259.     RCB
  260.         This message will be sent out if the slave requires a
  261.         call back to the master - the slave will not accept a
  262.         call from the master but will call the master instead.
  263.  
  264.     ROK
  265.         This message will be returned if the sequence number that
  266.         was sent in the message, attached to the -Q switch, from 
  267.         the master is the same as that computed on the slave.
  268.  
  269.     RBADSEQ
  270.         Happens if the sequence numbers do not match.
  271.  
  272.     (Notes on the sequence number - if a machine does not keep
  273.      sequence numbers, the value is set to 0. If no -Q switch
  274.      is given in the master's line, the sequence number is
  275.      defaulted to 0.
  276.  
  277.      The sequence file, SQFILE, has the format
  278.  
  279.         <remotename> <number> <month>/<day>-<hour>:<min>
  280.  
  281.      where <remotename> is the name of a master and <number>
  282.      is the previous sequence number. If the <number> field
  283.      is not present, or if it is greater than 9998, it is
  284.      set to 0. The <number> field is an ascii representation
  285.      of the number. The stuff after the <number> is the time
  286.      the sequence number was last changed, this information
  287.      doesn't seem important.)
  288.  
  289. (4) The slave sends a message that identifies all the protocols that
  290.     it supports. It seems that BSD supports 'g' as the normal case.
  291.     Some sites, such as Allegra, support 'e' and 'g', and a few
  292.     sites support 'f' as well. I have no information about these
  293.     protocols. The exact message sent might look like
  294.  
  295.         \020Pefg\0
  296.  
  297.     where efg indicates that this slave supports the e,f and g 
  298.     protocols.
  299.  
  300. (5) The slave waits for a response from the master with the chosen
  301.     protocol. If the master has a protocol that is in common the
  302.     master will send the message
  303.  
  304.         \020U<proto>\0
  305.  
  306.     where <proto> is the protocol (letter) chosen. If no protocol
  307.     is in common, the master will send the message
  308.  
  309.         \020UN\0
  310.  
  311. (6) At this point both the slave and master agree to use the designated
  312.     protocol. The first thing that now happens is that the master
  313.     checks for work.
  314.  
  315. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  316.  
  317.             UUCP Work Phase
  318.             ===============
  319.  
  320.  
  321. Master                            Slave
  322. ------                            -----
  323.  
  324. (a) Master has UUCP Work
  325.  
  326.     (1) X file1 file2     ----->
  327.  
  328.                     <-----        XN        (2)
  329.                             XY
  330.  
  331.     When the master wants the slave to do a 'uux' command
  332.     it sends the X message. If the slave can't or won't
  333.     do it, the slave will send an XN message. Otherwise
  334.     it will send an XY message.
  335.  
  336. (b) Master wants to send a file
  337.  
  338.     (1) S file1 file2 user options  ----->
  339.  
  340.                     <-----        SN2        (2)
  341.                             SN4
  342.                             SY
  343.  
  344.             <---- <data exchanged>---->            (3)
  345.  
  346.  
  347.                     <-----        CY        (4)
  348.                             CN5
  349.  
  350.     If the master wishes to send a file to the slave, it will
  351.     send a S message to the slave. If the slave can or will do
  352.     the transfer, it sends a SY message. If the slave has a
  353.     problem creating work files, it sends a SN4 message. If
  354.     the target file can't be created (because of priv's etc)
  355.     it sends a SN2 message.
  356.  
  357.     The file1 argument is the source file, and file2 is the
  358.     (almost) target filename. If file2 is a directory, then
  359.     the target filename is composed of file2 concatenated
  360.     with the "last" part of the file1 argument. Note, if the
  361.     file2 argument begins with X, the request is targeted to
  362.     UUX and not the normal send.
  363.  
  364.     The user argument indicates who, if anyone, is to be notified
  365.     if the file has been copied. This user must be on the slave
  366.     system.
  367.  
  368.     I am not sure what the options argument does.
  369.  
  370.     After the data has been exchanged the slave will send one of
  371.     two messages to the master. A CY message indicates that every-
  372.     thing is ok. The message CN5 indicates that the slave had
  373.     some problem moving the file to it's permanent location. This
  374.     is not the same as a problem during the exchange of data : this
  375.     causes the slave to terminate operation.
  376.  
  377. (c) Master wishes to receive a file.
  378.  
  379.     (1) R file1 file2 user    ----->
  380.  
  381.                         <-----    RN2        (2)
  382.                             RY mode
  383.  
  384.     (3)        <---- <data exchanged> ---->
  385.  
  386.     (4)    CY        ----->
  387.         CN5
  388.  
  389.     If the master wishes the slave to send a file, the master sends
  390.     a R message. If the slave has the file and can send it, the
  391.     slave will respond with the RY message. If the slave can't find
  392.     the file, or won't send it the RN2 message is sent. It doesn't
  393.     appear that the 'mode' field of the RY message is used.
  394.  
  395.     The argument file1 is the file to transfer, unless it is a
  396.     directory. In this case the file to be transferred is built
  397.     of a concatenation of file1 with the "last" part of the file2
  398.     argument.
  399.  
  400.     If anything goes wrong with the data transfer, it results in
  401.     both the slave and the master terminating.
  402.  
  403.     After the data has been transferred, the master will send an
  404.     acknowledgement to the slave. If the transfer and copy to the
  405.     destination file has been successful, the master will send the
  406.     CY message. Otherwise it will send the CN5 message.
  407.  
  408. (d) Master has no work, or no more work.
  409.  
  410.     (1) H            ----->
  411.  
  412.                 <-----                HY    (2)
  413.                                 HN
  414.  
  415.     (3) HY            ----->
  416.  
  417.                 <----                HY    (4)
  418.  
  419.     (5) ...
  420.  
  421.     The transfer of control is initiated with the master sending
  422.     a H message. This message tells the slave that the master has
  423.     no work, and the slave should look for work.
  424.  
  425.     If the slave has no work it will respond with the HY message.
  426.     This will tell the master to send an HY message, and turn off
  427.     the selected protocol. When the HY message is received by the
  428.     slave, it turns off the selected protocol as well. Both the
  429.     master and slave enter the UUCP termination phase.
  430.  
  431.     If the slave does have work, it sends the HN message to the
  432.     master. At this point, the slave becomes the master. After
  433.     the master receives the HN message, it becomes the slave.
  434.     The whole sequence of sending work starts over again. Note,
  435.     the transmission of HN doesn't force the master to send any
  436.     other H messages : it waits for stuff  from the new master.
  437.  
  438. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  439.  
  440.  
  441.             UUCP Termination Sequence
  442.             =========================
  443.  
  444.  Master                                Slave
  445.  ------                                -----
  446.  
  447.  (1) \020OOOOOO\0        ----->
  448.  
  449.                 <-----            \020OOOOOOO\0 (2)
  450.  
  451.  
  452.  
  453.     At this point all conversation has completed normally.
  454.  
  455.  
  456. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  457.  
  458.             UUCP Data Transfers
  459.             ===================
  460.  
  461.     After the initial handshake the systems send messages in one
  462.     of two styles : packet and not packet. A Packet protocol is
  463.     just raw data transfers : there is no protocol or acknowledgements;
  464.     this appears to assume that the lower level is a packet network
  465.     of some type. If the style is not Packet, then extra work is
  466.     done. I am still working on this stuff.
  467.  
  468.   =====================================================
  469.   -- part 2
  470.   =====================================================
  471.  
  472.   ** summary of UUCP packets ** 
  473.   (this is much like part 1, but shortened and compared against a
  474.   live UUCP ~uucp_adm/uucico)
  475.  
  476.   note that all transmissions end with a null, not shown here
  477.  
  478.  
  479. (master)        (slave)
  480.  
  481.  ... dials up ...    <DLE>Shere        says "hello"
  482.  
  483. <DLE>S<sysname> <opts>                says who he is
  484.  
  485.         |    <DLE>ROK        says ok to talk
  486.         |    <DLE>RLCK        says locked out
  487.         |    <DLE>RCB        says will call back
  488.         |    <DLE>RBADSEQ        says bad seq num
  489.  
  490.             <DLE>P<protos>        what protocols he has
  491.  
  492. <DLE>U<proto>    |                which to use
  493. <DLE>UN        |                use none, hang up
  494.  
  495.  
  496. packet driver is turned on at this time, if not told otherwise
  497.  
  498.  -- if master has work --
  499.  
  500. to send file to slave...
  501. S <mfilenm> <sfilenm> <user> <opts>        request to send file
  502.  
  503.         |    SY            ok -- i'll take it
  504.         |    SN2            not permitted
  505.         |    SN4            can't make workfile
  506.  
  507. <data>                        the file is transmitted
  508.  
  509.         |    CY            finished OK
  510.         |    CN5            can't move into place
  511.  
  512.  
  513. to recv file from slave...
  514. R <sfilenm> <mfilenm> <user>            request to recv file
  515.  
  516.         |    RY<mode>        ok -- here is prot mode
  517.         |    RN2            not permitted
  518.  
  519.             <data>            file is transmitted
  520.  
  521. CY        |                worked
  522. CN5        |                can't move into place
  523.  
  524.  
  525. to do UUX on slave...
  526. X <file1> <file2>                request to exec file
  527.  
  528.         |    XY            ok -- will do
  529.         |    XN            nopers
  530.  
  531. to indicate that he has no more work...
  532. H                        no more work
  533.  
  534.         |    HN            reverse roles
  535.         |    HY            no work here either
  536.  
  537. to accept slave's claim of no more work...
  538.  
  539. HY                        agrees to hang up
  540.  
  541. the rest of the hang-up is done OUTSIDE of packet driver
  542. <DLE>OOOOOO                    signs off (6*'O')
  543.  
  544.             <DLE>OOOOOOO        signs off (7*'O')
  545.     
  546.  
  547. If the slave has work, then the roles are reversed, and the session
  548. proceeds from the label 'loop1' above.  The system which was the slave
  549. is now the master, and the old master is just the slave. 
  550.  
  551. The <opts> which follow the system name for the start-up sequence
  552. include:
  553.     -g        don't use packet driver (command line -G)
  554.     -xN        debug level (command line -Xn)
  555.     -QN        seq number (if systems use this)
  556.  
  557. The filenames for <mfilenm> should be complete filenames with path
  558. information; otherwise they are assumed to be in /usr/spool/uucp.  The
  559. filenames for <sfilenm> should be either complete filenames or directory
  560. names.  If directory names are used, then the final componant of
  561. <mfilenm> is appended to form the complete filename. 
  562.  
  563. The 'X' command to do UUX on a slave is more than a little unclear.  It
  564. doesn't seem to work here, but that may be a microsoft "feature". 
  565.  
  566.  
  567. Protocol "g", which seems to be the one most commonly used, is supposed
  568. to be a slightly munged version of level 2 of X.25; an article was just
  569. posted in net.unix-wizards (which you probably have already seen) to
  570. this effect.  The article didn't provide any details on the protocol,
  571. but merely mentioned the modifications. 
  572.  
  573. The "packet" mode, with no protocol, does not work under microsoft
  574. implementations, and may have *lots* of trouble working anywhere else as
  575. well.  It evidently requires that zero-length reads happen every so
  576. often to delimit things, such as files being transferred.  This of
  577. course can't happen without the packet driver, which was long gone by
  578. the time sys-3 or sys-5 or <your current version> came along. 
  579.  
  580.   **********************************
  581.   ** end of issue #2
  582.   **********************************
  583.  
  584.  
  585. >From: ihnp4!akgua!ucf-cs!ki4pv!tanner
  586. To: ucf-cs!ki4pv-uucpinfo, allegra!mp
  587. Subject: UUCP INFO mailing list issue #03
  588. Date: Sun Jan 12 19:11:18 1986
  589.  
  590. The following information, describing the uucp 'g' protocol, was
  591. provided as "nroff" source.  Cut the header and this text off of
  592. the message, and run it through "nroff".
  593. ..ce
  594. ..B
  595. Packet Driver Protocol
  596. ..R
  597. ..sp 1
  598. ..ce
  599. G. L. Chesson
  600. ..br
  601. ..ce
  602. Bell Laboratories
  603. ..SH
  604. Abstract
  605. ..in +.5i
  606. ..PP
  607. These notes describe the packet driver link
  608. protocol that was supplied
  609. with the
  610. Seventh Edition of
  611. ..UX
  612. and is used by the UUCP program.
  613. ..in -.5i
  614. ..SH
  615. General
  616. ..PP
  617. Information flow between a pair of machines
  618. may be regulated by
  619. first
  620. representing the data 
  621. as sequence-numbered 
  622. ..I
  623. packets
  624. ..R
  625. of data 
  626. and then establishing conventions that
  627. govern the use of sequence numbers.
  628. The
  629. ..I
  630. PK,
  631. ..R
  632. or
  633. ..I
  634. packet driver,
  635. ..R
  636. protocol
  637. is a particular instance of this type of
  638. flow-control discipline.
  639. The technique depends on the notion of a transmission
  640. ..I
  641. window
  642. ..R
  643. to determine upper and lower bounds for valid
  644. sequence numbers.
  645. The transmitter is allowed to retransmit packets
  646. having sequence numbers
  647. within the window until the receiver indicates that
  648. packets have been correctly received.
  649. Positive acknowledgement from the receiver moves the
  650. window;
  651. negative acknowledgement or no acknowledgement
  652. causes retransmission.
  653. The receiver must ignore duplicate transmission, detect
  654. the various errors that may occur,
  655. and inform the transmitter when packets are 
  656. correctly or incorrectly received.
  657. ..PP
  658. The following paragraphs describe the packet formats,
  659. message exchanges,
  660. and framing
  661. used by the protocol as coded
  662. in the UUCP program and the
  663. ..UX
  664. kernel.
  665. Although no attempt will be made here to present
  666. internal details of the algorithms that were used,
  667. the checksum routine is supplied
  668. for the benefit of other implementors.
  669. ..SH
  670. Packet Formats
  671. ..PP
  672. The protocol is defined in terms of message
  673. transmissions of 8-bit bytes.
  674. Each message includes one
  675. ..I
  676. control
  677. ..R
  678. byte plus a
  679. ..I
  680. data segment
  681. ..R
  682. of zero or more information bytes.
  683. The allowed data segment sizes range
  684. between 32 and 4096 as determined by the formula
  685. 32(2\uk\d) where
  686. k is a 3-bit number.
  687. The packet sequence numbers are likewise constrained
  688. to 3-bits; i.e. counting proceeds modulo-8.
  689. ..PP
  690. The control byte is partitioned into three fields as
  691. depicted below.
  692. ..bp
  693. ..nf
  694. ..sp 
  695. ..in 1i
  696. ..ls 1
  697. bit    7    6    5    4    3    2    1    0
  698.     t    t    x    x    x    y    y    y
  699. ..ls 1
  700. ..in -1i
  701. ..fi
  702. ..sp
  703. The
  704. ..I
  705. t
  706. ..R
  707. bits indicate a packet type and
  708. determine the interpretation to be placed on
  709. the
  710. ..I
  711. xxx
  712. ..R
  713. and
  714. ..I
  715. yyy
  716. ..R
  717. fields.
  718. The various interpretations are as follows:
  719. ..in +1i
  720. ..sp
  721. ..nf
  722. ..ls 1
  723. ..I
  724. tt    interpretation
  725. ..sp
  726. ..R
  727. 00    control packet
  728. 10    data packet
  729. 11    `short' data packet
  730. 01    alternate channel
  731. ..ls 1
  732. ..fi
  733. ..sp
  734. ..in -1i
  735. A data segment accompanies all non-control packets.
  736. Each transmitter is constrained to observe the maximum
  737. data segment size
  738. established during initial synchronization by the
  739. receiver that it sends to.
  740. Type 10 packets have maximal size data segments.
  741. Type 11, or `short', packets have zero or more data
  742. bytes but less than the maximum.
  743. The first one or two bytes of the data segment of a
  744. short packet are `count' bytes that
  745. indicate the difference between the
  746. maximum size and the number of bytes in the short
  747. segment.
  748. If the difference is less than 127, one count
  749. byte is used.
  750. If the difference exceeds 127,
  751. then the low-order seven bits of the difference
  752. are put in the first data byte and the high-order
  753. bit is set as an indicator that the remaining
  754. bits of the difference are in the second byte.
  755. Type 01 packets are never used by UUCP
  756. and need not be discussed in detail here.
  757. ..PP
  758. The sequence number of a non-control packet is
  759. given by the
  760. ..I
  761. xxx
  762. ..R
  763. field.
  764. Control packets are not sequenced.
  765. The newest sequence number,
  766. excluding duplicate transmissions,
  767. accepted by a receiver is placed in the
  768. ..I
  769. yyy
  770. ..R
  771. field of non-control packets sent to the
  772. `other' receiver.
  773. ..PP
  774. There are no data bytes associated with a control packet,
  775. the
  776. ..I
  777. xxx
  778. ..R
  779. field is interpreted as a control message,
  780. and the
  781. ..I
  782. yyy
  783. ..R
  784. field is a value accompanying the control message.
  785. The control messages are listed below in decreasing priority.
  786. That is, if several control messages are to be sent,
  787. the lower-numbered ones are sent first.
  788. ..in +1i
  789. ..nf
  790. ..ls 1
  791. ..sp
  792. ..I
  793. xxx    name        yyy
  794. ..R
  795.  
  796. 1    CLOSE    n/a
  797. 2    RJ        last correctly received sequence number
  798. 3    SRJ        sequence number to retransmit
  799. 4    RR        last correctly received sequence number
  800. 5    INITC    window size
  801. 6    INITB    data segment size
  802. 7    INITA    window size
  803. ..in -i
  804. ..ls 1
  805. ..fi
  806. ..sp
  807. ..PP
  808. The CLOSE message indicates that the communications channel
  809. is to be shut down.
  810. The RJ, or
  811. ..I
  812. reject,
  813. ..R
  814. message indicates that the receiver has detected an error
  815. and the sender should retransmit after using the 
  816. ..I
  817. yyy
  818. ..R
  819. field to update the window.
  820. This mode of retransmission is usually
  821. referred to as a
  822. `go-back-N' procedure.
  823. The SRJ, or
  824. ..I
  825. selective reject,
  826. ..R
  827. message carries with it the sequence number of
  828. a particular packet to be retransmitted.
  829. The RR, or
  830. ..I
  831. receiver ready,
  832. ..R
  833. message indicates that the receiver has detected
  834. no errors; the
  835. ..I
  836. yyy
  837. ..R
  838. field updates the sender's window.
  839. The INITA/B/C messages are used
  840. to set window and data segment sizes.
  841. Segment sizes are calculated by the formula
  842. 32(2\uyyy\d)
  843. as mentioned above,
  844. and window sizes may range between 1 and 7.
  845. ..PP
  846. Measurements of the protocol running on communication
  847. links at rates up to 9600 baud showed that
  848. a window size of 2 is optimal
  849. given a packet size greater than 32 bytes.
  850. This means that the link bandwidth can be fully utilized
  851. by the software.
  852. For this reason the SRJ message is not as important as it
  853. might otherwise be.
  854. Therefore the
  855. ..UX
  856. implementations no longer generate or respond to SRJ
  857. messages.
  858. It is mentioned here for historical accuracy only,
  859. and one may assume that SRJ is no longer part of the protocol.
  860. ..SH
  861. Message Exchanges
  862. ..SH
  863.     Initialization
  864. ..PP
  865. Messages are exchanged between four cooperating
  866. entities: two senders and two receivers.
  867. This means that the communication channel is thought of
  868. as two independent half-duplex data paths.
  869. For example the window and segment sizes need not
  870. be the same in each direction.
  871. ..PP
  872. Initial synchronization is accomplished
  873. with two 3-way handshakes: two each of
  874. INITA/INITB/INITC.
  875. Each sender transmits INITA messages repeatedly.
  876. When an INITA message is received, INITB is
  877. sent in return.
  878. When an INITB message is received
  879. ..I
  880. and
  881. ..R
  882. an INITB message has been sent,
  883. an INITC message is sent.
  884. The INITA and INITB messages carry 
  885. with them the packet and window size that
  886. each receiver wants to use,
  887. and the senders are supposed to comply.
  888. When a receiver has seen all three
  889. INIT messages, the channel is 
  890. considered to be open.
  891. ..PP
  892. It is possible to design a protocol that starts up using
  893. fewer messages than the interlocked handshakes described above.
  894. The advantage of the more complicated design lies in its use as
  895. a research vehicle:
  896. the initial handshake sequence is completely symmetric,
  897. a handshake
  898. can be initiated by one side of the link while the
  899. connection is in use, and the software to do this can
  900. utilize code that would ordinarily be used only once
  901. at connection setup time.
  902. These properties were used in experiments with dynamically
  903. adjusted parameters.
  904. That is attempts were made to adapt the window and segment
  905. sizes to changes observed in traffic while a link was in use.
  906. Other experiments used the initial
  907. handshake  in a different way
  908. for restarting the protocol without data loss
  909. after machine crashes.
  910. These experiments never worked well in the packet driver and
  911. basically provided the impetus for other protocol designs.
  912. The result 
  913. as far as UUCP is concerned is that initial synchronization
  914. uses the two 3-way handshakes, and the INIT
  915. messages are ignored elsewhere.
  916. ..SH
  917.     Data Transport
  918. ..PP
  919. After initial synchronization each receiver
  920. sets a modulo-8 incrementing counter R to 0;
  921. each sender sets a similar counter S to 1.
  922. The value of R is always the number of the most recent
  923. correctly received packet.
  924. The value of S is always the first sequence number in
  925. the output window.
  926. Let W denote window size.
  927. Note that the value of W may be different for each sender.
  928. ..PP
  929. A sender may transmit packets with sequence numbers
  930. in the range S to (S+W-1)\ mod-8.
  931. At any particular time a receiver expects
  932. arriving packets to have numbers in the range
  933. (R+1)\ mod-8 to (R+W)\ mod-8.
  934. Packets must arrive in sequence number order
  935. are are only acknowledged in order.
  936. That is,
  937. the `next' packet a receiver
  938. will acknowledge must have
  939. sequence number (R+1)\ mod-8.
  940. ..PP
  941. A receiver acknowledges receipt of data packets
  942. by arranging for the value of its R counter to be
  943. sent across the channel
  944. where it will be used to update an S counter.
  945. This is done in two ways.
  946. If data is flowing in both directions across a
  947. channel then each receiver's current R value is
  948. carried in the
  949. ..I
  950. yyy
  951. ..R
  952. field of non-control packets.
  953. Otherwise when there is no bidirectional
  954. data flow,
  955. each receiver's R value is transmitted across the link
  956. as the
  957. ..I
  958. yyy
  959. ..R
  960. field of an RR control packet.
  961. ..PP
  962. Error handling is up to the discretion
  963. of the receiver.
  964. It can ignore all errors in which case
  965. transmitter timeouts must provide for
  966. retransmission.
  967. The receiver may also generate RJ 
  968. error control packets.
  969. The
  970. ..I
  971. yyy
  972. ..R
  973. field of an incoming RJ message replaces
  974. the S value of the local sender and
  975. constitutes a request for retransmission to start
  976. at that sequence number.
  977. The
  978. ..I
  979. yyy
  980. ..R
  981. field of an incoming SRJ message selects a particular
  982. packet for retransmission.
  983. ..PP
  984. The resemblance between the flow control procedure in the
  985. packet driver and that defined for X.25 is no accident.
  986. The packet driver protocol began life as an attempt at
  987. cleaning up X.25.
  988. That is why, for example,
  989. control information is uniform in length (one byte),
  990. there is no RNR message (not needed),
  991. and there is but one timeout defined
  992. in the sender.
  993. ..SH
  994.     Termination
  995. ..PP
  996. The CLOSE message is used to terminate communications.
  997. Software on either or both ends of the communication
  998. channel may initiate termination.
  999. In any case when one end wants to terminate it sends
  1000. CLOSE messages until one is received from the other end
  1001. or until a programmable limit on the number of CLOSE
  1002. messages is reached.
  1003. Receipt of a CLOSE message causes a CLOSE message to be sent.
  1004. In the 
  1005. ..UX
  1006. environment
  1007. it also causes the SIGPIPE or
  1008. `broken pipe' signal to be sent to
  1009. the local process using the communication channel.
  1010. ..SH
  1011.     Framing
  1012. ..PP
  1013. The term
  1014. ..I
  1015. framing
  1016. ..R
  1017. is used to denote the technique by which the
  1018. beginning and end of a message is detected
  1019. in a byte stream;
  1020. ..I
  1021. error control
  1022. ..R
  1023. denotes the method by which transmission
  1024. errors are detected.
  1025. Strategies for framing and error control depend
  1026. upon
  1027. additional information being transmitted along
  1028. with the control byte and data segment,
  1029. and the choice of a particular strategy usually
  1030. depends on characteristics of input/output
  1031. devices and transmission media.
  1032. ..PP
  1033. Several framing techniques are in used in support
  1034. of PK protocol implementations,
  1035. not all of which can be described in detail here.
  1036. The technique used on asynchronous serial lines
  1037. will be described.
  1038. ..PP
  1039. A six byte
  1040. framing
  1041. ..I
  1042. envelope
  1043. ..R
  1044. is constructed using the control byte
  1045. C of a packet and five other bytes as
  1046. depicted below.
  1047. ..in +1i
  1048. <DLE><k><c0><c1><C><x>
  1049. ..in -1i
  1050. The <DLE> symbol denotes the ASCII ctrl/P character.
  1051. If the envelope is to be followed by a data segment,
  1052. <k> has the value
  1053. log\d2\u(size)-4;
  1054. i.e. 1 \(<= k \(<= 8.
  1055. If k is 9, then the envelope represents a control packet.
  1056. The <c0> and <c1> bytes are the low-order and high-order
  1057. bytes respectively of a 16-bit checksum of the data segment,
  1058. if there is one.
  1059. For control packets <c1> is zero and <c0> is the same
  1060. as the control byte C.
  1061. The <x> byte is the exclusive-or of <k><c0><c1><C>.
  1062. Error control is accomplished by checking 
  1063. a received framing envelope for compliance with the definition,
  1064. and comparing a checksum function of the data segment
  1065. with <c0><c1>.
  1066. ..PP
  1067. This particular framing strategy assumes data segments
  1068. are constant-sized:
  1069. the `unused' bytes in a short packet are actually
  1070. transmitted.
  1071. This creates a certain amount of overhead which
  1072. can be eliminated by a more complicated framing technique.
  1073. The advantage of this strategy is that i/o
  1074. devices can be programmed to take advantage of the
  1075. constant-sized framing envelopes and data segments.
  1076. ..bp
  1077. ..PP
  1078. The checksum calculation is displayed below as a C function.
  1079. Note that the code is not truly portable because
  1080. the definitions of
  1081. ..I short
  1082. and
  1083. ..I char
  1084. are not necessarily uniform across all machines
  1085. that might support this language.
  1086. This code assumes that
  1087. ..I short
  1088. and
  1089. ..I char
  1090. are 16 and 8-bits respectively.
  1091. ..PP
  1092. ..in +.5i
  1093. ..nf
  1094. ..ft CW
  1095. ..ls 1
  1096. /* [Original document's version corrected to actual version] */
  1097. chksum(s,n)
  1098. register char *s;
  1099. register n;
  1100. {
  1101.     register short sum;
  1102.     register unsigned short t;
  1103.     register short x;
  1104.  
  1105.     sum = -1;
  1106.     x = 0;
  1107.  
  1108.     do {
  1109.         if (sum<0) {
  1110.             sum <<= 1;
  1111.             sum++;
  1112.         } else
  1113.             sum <<= 1;
  1114.         t = sum;
  1115.         sum += (unsigned)*s++ & 0377;
  1116.         x += sum^n;
  1117.         if ((unsigned short)sum <= t) {
  1118.             sum ^= x;
  1119.         }
  1120.     } while (--n > 0);
  1121.  
  1122.     return(sum);
  1123. }
  1124. ..fi
  1125. ..in -.5i
  1126. ..ft R
  1127. -- 
  1128. John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   gnu@ingres.berkeley.edu
  1129. Love your country but never trust its government.
  1130.              -- from a hand-painted road sign in central Pennsylvania
  1131. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
  1132.  
  1133.   The deroffed version
  1134.  
  1135. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
  1136.  
  1137. Packet Driver Protocol
  1138.  
  1139. G. L. Chesson
  1140.  
  1141. Bell Laboratories
  1142.  
  1143. Abstract
  1144.  
  1145. These notes describe the packet driver link protocol that was supplied
  1146. with the Seventh Edition of and is used by the UUCP program.
  1147.  
  1148. General
  1149.  
  1150. Information flow between a pair of machines may be regulated by first
  1151. representing the data as sequence-numbered packets of data and then
  1152. establishing conventions that govern the use of sequence numbers.  The
  1153. PK, or packet driver, protocol is a particular instance of this type
  1154. of flow-control discipline.  The technique depends on the notion of a
  1155. transmission window to determine upper and lower bounds for valid
  1156. sequence numbers.  The transmitter is allowed to retransmit packets
  1157. having sequence numbers within the window until the receiver indicates
  1158. that packets have been correctly received.  Positive acknowledgement
  1159. from the receiver moves the window; negative acknowledgement or no
  1160. acknowledgement causes retransmission.  The receiver must ignore
  1161. duplicate transmission, detect the various errors that may occur, and
  1162. inform the transmitter when packets are correctly or incorrectly
  1163. received.
  1164.  
  1165. The following paragraphs describe the packet formats, message
  1166. exchanges, and framing used by the protocol as coded in the UUCP
  1167. program and the kernel.
  1168.  
  1169. Although no attempt will be made here to present internal details of
  1170. the algorithms that were used, the checksum routine is supplied for
  1171. the benefit of other implementors.
  1172.  
  1173. Packet Formats
  1174.  
  1175. The protocol is defined in terms of message transmissions of 8-bit
  1176. bytes.
  1177.  
  1178. Each message includes one control byte plus a data segment of zero or
  1179. more information bytes.  The allowed data segment sizes range between
  1180. 32 and 4096 as determined by the formula 32(2 k ) where k is a 3-bit
  1181. number.  The packet sequence numbers are likewise constrained to
  1182. 3-bits; i.e. counting proceeds modulo-8.
  1183.  
  1184. The control byte is partitioned into three fields as depicted below.
  1185.   
  1186. bit    7    6    5    4    3    2    1    0
  1187.     t    t    x    x    x    y    y    y
  1188.   
  1189.  
  1190. The t bits indicate a packet type and determine the interpretation to
  1191. be placed on the xxx and yyy fields.  The various interpretations are
  1192. as follows:
  1193.   
  1194. tt    interpretation
  1195.  
  1196. 00    control packet
  1197. 10    data packet
  1198. 11    `short' data packet
  1199. 01    alternate channel
  1200.   
  1201. A data segment accompanies all non-control packets.  Each transmitter
  1202. is constrained to observe the maximum data segment size established
  1203. during initial synchronization by the receiver that it sends to.
  1204.  
  1205. Type 10 packets have maximal size data segments.
  1206.  
  1207. Type 11, or `short', packets have zero or more data bytes but less
  1208. than the maximum.
  1209.  
  1210. The first one or two bytes of the data segment of a short packet are
  1211. `count' bytes that indicate the difference between the maximum size
  1212. and the number of bytes in the short segment.
  1213.  
  1214. If the difference is less than 127, one count byte is used.
  1215.  
  1216. If the difference exceeds 127, then the low-order seven bits of the
  1217. difference are put in the first data byte and the high-order bit is
  1218. set as an indicator that the remaining bits of the difference are in
  1219. the second byte.  Type 01 packets are never used by UUCP and need not
  1220. be discussed in detail here.
  1221.  
  1222. The sequence number of a non-control packet is given by the xxx field.
  1223.  
  1224. Control packets are not sequenced.  The newest sequence number,
  1225. excluding duplicate transmissions, accepted by a receiver is placed in
  1226. the yyy field of non-control packets sent to the `other' receiver.
  1227.  
  1228. There are no data bytes associated with a control packet, the xxx
  1229. field is interpreted as a control message, and the yyy field is a
  1230. value accompanying the control message.
  1231.  
  1232. The control messages are listed below in decreasing priority.  That
  1233. is, if several control messages are to be sent, the lower-numbered
  1234. ones are sent first.
  1235.  
  1236. xxx    name    yyy
  1237. 1    CLOSE    n/a
  1238. 2    RJ    last correctly received sequence number
  1239. 3    SRJ    sequence number to retransmit
  1240. 4    RR    last correctly received sequence number
  1241. 5    INITC    window size
  1242. 6    INITB    data segment size
  1243. 7    INITA    window size
  1244.  
  1245. The CLOSE message indicates that the communications channel is to be
  1246. shut down.
  1247.  
  1248. The RJ, or reject, message indicates that the receiver has detected an
  1249. error and the sender should retransmit after using the yyy field to
  1250. update the window.
  1251.  
  1252. This mode of retransmission is usually referred to as a `go-back-N'
  1253. procedure.
  1254.  
  1255. The SRJ, or selective reject, message carries with it the sequence
  1256. number of a particular packet to be retransmitted.
  1257.  
  1258. The RR, or receiver ready, message indicates that the receiver has
  1259. detected no errors; the yyy field updates the sender's window.
  1260.  
  1261. The INITA/B/C messages are used to set window and data segment sizes.
  1262.  
  1263. Segment sizes are calculated by the formula 32(2 yyy ) as mentioned
  1264. above, and window sizes may range between 1 and 7.
  1265.  
  1266. Measurements of the protocol running on communication links at rates
  1267. up to 9600 baud showed that a window size of 2 is optimal given a
  1268. packet size greater than 32 bytes.
  1269.  
  1270. This means that the link bandwidth can be fully utilized by the
  1271. software.
  1272.  
  1273. For this reason the SRJ message is not as important as it might
  1274. otherwise be.  Therefore the implementations no longer generate or
  1275. respond to SRJ messages.  It is mentioned here for historical accuracy
  1276. only, and one may assume that SRJ is no longer part of the protocol.
  1277.  
  1278. Message Exchanges
  1279.  
  1280.     Initialization
  1281.  
  1282. Messages are exchanged between four cooperating entities: two senders
  1283. and two receivers.  This means that the communication channel is
  1284. thought of as two independent half-duplex data paths.  For example the
  1285. window and segment sizes need not be the same in each direction.
  1286.  
  1287. Initial synchronization is accomplished with two 3-way handshakes: two
  1288. each of INITA/INITB/INITC.
  1289.  
  1290. Each sender transmits INITA messages repeatedly.  When an INITA
  1291. message is received, INITB is sent in return.
  1292.  
  1293. When an INITB message is received and an INITB message has been sent,
  1294. an INITC message is sent.
  1295.  
  1296. The INITA and INITB messages carry with them the packet and window
  1297. size that each receiver wants to use, and the senders are supposed to
  1298. comply.
  1299.  
  1300. When a receiver has seen all three INIT messages, the channel is
  1301. considered to be open.
  1302.  
  1303. It is possible to design a protocol that starts up using fewer
  1304. messages than the interlocked handshakes described above.
  1305.  
  1306. The advantage of the more complicated design lies in its use as a
  1307. research vehicle: the initial handshake sequence is completely
  1308. symmetric, a handshake can be initiated by one side of the link while
  1309. the connection is in use, and the software to do this can utilize code
  1310. that would ordinarily be used only once at connection setup time.
  1311.  
  1312. These properties were used in experiments with dynamically adjusted
  1313. parameters.
  1314.  
  1315. That is attempts were made to adapt the window and segment sizes to
  1316. changes observed in traffic while a link was in use.
  1317.  
  1318. Other experiments used the initial handshake in a different way for
  1319. restarting the protocol without data loss after machine crashes.
  1320.  
  1321. These experiments never worked well in the packet driver and basically
  1322. provided the impetus for other protocol designs.
  1323.  
  1324. The result as far as UUCP is concerned is that initial synchronization
  1325. uses the two 3-way handshakes, and the INIT messages are ignored
  1326. elsewhere.
  1327.  
  1328.     Data Transport
  1329.  
  1330. After initial synchronization each receiver sets a modulo-8
  1331. incrementing counter R to 0; each sender sets a similar counter S to 1.
  1332.  
  1333. The value of R is always the number of the most recent correctly
  1334. received packet.
  1335.  
  1336. The value of S is always the first sequence number in the output
  1337. window.  Let W denote window size.  Note that the value of W may be
  1338. different for each sender.
  1339.  
  1340. A sender may transmit packets with sequence numbers in the range S to
  1341. (S+W-1) mod-8.  At any particular time a receiver expects arriving
  1342. packets to have numbers in the range (R+1) mod-8 to (R+W) mod-8.
  1343. Packets must arrive in sequence number order are are only acknowledged
  1344. in order.
  1345.  
  1346. That is, the `next' packet a receiver will acknowledge must have
  1347. sequence number (R+1) mod-8.
  1348.  
  1349. A receiver acknowledges receipt of data packets by arranging for the
  1350. value of its R counter to be sent across the channel where it will be
  1351. used to update an S counter.
  1352.  
  1353. This is done in two ways.  If data is flowing in both directions
  1354. across a channel then each receiver's current R value is carried in
  1355. the yyy field of non-control packets.
  1356.  
  1357. Otherwise when there is no bidirectional data flow, each receiver's R
  1358. value is transmitted across the link as the yyy field of an RR control
  1359. packet.
  1360.  
  1361. Error handling is up to the discretion of the receiver.
  1362.  
  1363. It can ignore all errors in which case transmitter timeouts must
  1364. provide for retransmission.
  1365.  
  1366. The receiver may also generate RJ error control packets.  The yyy
  1367. field of an incoming RJ message replaces the S value of the local
  1368. sender and constitutes a request for retransmission to start at that
  1369. sequence number.
  1370.  
  1371. The yyy field of an incoming SRJ message selects a particular packet
  1372. for retransmission.
  1373.  
  1374. The resemblance between the flow control procedure in the packet
  1375. driver and that defined for X.25 is no accident.  The packet driver
  1376. protocol began life as an attempt at cleaning up X.25.
  1377.  
  1378. That is why, for example, control information is uniform in length
  1379. (one byte), there is no RNR message (not needed), and there is but one
  1380. timeout defined in the sender.
  1381.  
  1382.     Termination
  1383.  
  1384. The CLOSE message is used to terminate communications.  Software on
  1385. either or both ends of the communication channel may initiate
  1386. termination.
  1387.  
  1388. In any case when one end wants to terminate it sends CLOSE messages
  1389. until one is received from the other end or until a programmable limit
  1390. on the number of CLOSE messages is reached.
  1391.  
  1392. Receipt of a CLOSE message causes a CLOSE message to be sent.  In the
  1393. environment it also causes the SIGPIPE or `broken pipe' signal to be
  1394. sent to the local process using the communication channel.
  1395.  
  1396.     Framing
  1397.  
  1398. The term framing is used to denote the technique by which the
  1399. beginning and end of a message is detected in a byte stream; error
  1400. control denotes the method by which transmission errors are detected.
  1401.  
  1402. Strategies for framing and error control depend upon additional
  1403. information being transmitted along with the control byte and data
  1404. segment, and the choice of a particular strategy usually depends on
  1405. characteristics of input/output devices and transmission media.
  1406.  
  1407. Several framing techniques are in used in support of PK protocol
  1408. implementations, not all of which can be described in detail here.
  1409.  
  1410. The technique used on asynchronous serial lines will be described.
  1411.  
  1412. A six byte framing envelope is constructed using the control byte C of
  1413. a packet and five other bytes as depicted below.
  1414.   
  1415. <DLE><k><c0><c1><C><x>
  1416.   
  1417. The <DLE> symbol denotes the ASCII ctrl/P character.  If the envelope
  1418. is to be followed by a data segment, <k> has the value
  1419.  
  1420. log 2 (size)-4;
  1421.  
  1422. i.e. 1   k   8.
  1423.  
  1424. If k is 9, then the envelope represents a control packet.
  1425.  
  1426. The <c0> and <c1> bytes are the low-order and high-order bytes
  1427. respectively of a 16-bit checksum of the data segment, if there is
  1428. one.
  1429.  
  1430. For control packets <c1> is zero and <c0> is the same as the control
  1431. byte C.
  1432.  
  1433. The <x> byte is the exclusive-or of <k><c0><c1><C>.
  1434.  
  1435. Error control is accomplished by checking a received framing envelope
  1436. for compliance with the definition, and comparing a checksum function
  1437. of the data segment with <c0><c1>.
  1438.  
  1439. This particular framing strategy assumes data segments are
  1440. constant-sized: the `unused' bytes in a short packet are actually
  1441. transmitted.
  1442.  
  1443. This creates a certain amount of overhead which can be eliminated by a
  1444. more complicated framing technique.  The advantage of this strategy is
  1445. that i/o devices can be programmed to take advantage of the
  1446. constant-sized framing envelopes and data segments.
  1447.  
  1448. The checksum calculation is displayed below as a C function.  Note
  1449. that the code is not truly portable because the definitions of
  1450.  
  1451.     short
  1452. and
  1453.     char
  1454.  
  1455. are not necessarily uniform across all machines that might support
  1456. this language.
  1457.  
  1458. This code assumes that
  1459.  
  1460.     short
  1461. and
  1462.     char
  1463. are 16 and 8-bits respectively.
  1464.  
  1465.  
  1466.   CW
  1467.   
  1468. /* [Original document's version corrected to actual version] */
  1469. chksum(s,n)
  1470. register char *s;
  1471. register n;
  1472. {
  1473.     register short sum;
  1474.     register unsigned short t;
  1475.     register short x;
  1476.     sum = -1;
  1477.     x = 0;
  1478.     do {
  1479.         if (sum<0) {
  1480.             sum <<= 1;
  1481.             sum++;
  1482.         } else
  1483.             sum <<= 1;
  1484.         t = sum;
  1485.         sum += (unsigned)*s++ & 0377;
  1486.         x += sum^n;
  1487.         if ((unsigned short)sum <= t) {
  1488.             sum ^= x;
  1489.         }
  1490.     } while (--n > 0);
  1491.     return(sum);
  1492. }
  1493.  
  1494. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
  1495.  
  1496.